VERSION 5.00
Begin VB.Form findwin 
   Appearance      =   0  'Flat
   BackColor       =   &H80000005&
   Caption         =   "Current Windows Open"
   ClientHeight    =   2265
   ClientLeft      =   2925
   ClientTop       =   1770
   ClientWidth     =   4365
   BeginProperty Font 
      Name            =   "MS Sans Serif"
      Size            =   8.25
      Charset         =   0
      Weight          =   700
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   ForeColor       =   &H80000008&
   LinkTopic       =   "Form1"
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   2265
   ScaleWidth      =   4365
   Begin VB.ListBox List1 
      Height          =   2010
      Left            =   120
      TabIndex        =   0
      Top             =   0
      Width           =   4095
   End
   Begin VB.Menu mnuFile 
      Caption         =   "&File"
      Begin VB.Menu mnuRefresh 
         Caption         =   "Refresh"
      End
      Begin VB.Menu mnuExit 
         Caption         =   "E&xit"
      End
   End
End
Attribute VB_Name = "findwin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public prog As String
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As Any, _
ByVal lpWindowName As Any) As Long
Private Declare Function GetWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hwnd As Long, _
ByVal lpString As String, ByVal nMaxCount As Long) As Long
Private Declare Function GetParent Lib "user32.dll" (ByVal hwnd As Long) As Long
Private Function findwindowpartial(ByVal titlepart$, method%) As Long
    Dim hwndtmp As Long
    Dim nret As Long
    Dim titletmp As String

    titlepart = UCase(titlepart)
    hwndtmp = FindWindow(0&, 0&)
    Do Until hwndtmp = 0
        If GetParent(hwndtmp) = 0 Then
            titletmp = Space(256)
            nret = GetWindowText(hwndtmp, titletmp, Len(titletmp))
            If nret Then
                titletmp = UCase(Left(titletmp, nret))
                        If InStr(titletmp, titlepart) = 1 Then
                            findwindowpartial = hwndtmp
                            Exit Do
                        End If
            End If
        End If
        hwndtmp = GetWindow(hwndtmp, gw_hwndnext)
    Loop
    title = titletmp
End Function




Private Sub appactivatepartial(titlecontains$, method%)
    Dim hwndapp As Long
    Dim nret As Long

    hwndapp = findwindowpartial(titlecontains, method)
    If hwndapp Then
        If title <> "CURRENT WINDOWS OPEN" Then List1.AddItem title
    End If
End Sub



Private Sub Form_Load()
    Dim prog As String
    For i = 65 To 90
        prog = Chr(i)
        appactivatepartial prog, fwp_startswith
    Next
End Sub

Private Sub mnuExit_Click()
    End
End Sub

Private Sub mnuRefresh_Click()
    List1.Clear
    Dim prog As String
    For i = 65 To 90
        prog = Chr(i)
        appactivatepartial prog, fwp_startswith
    Next
End Sub
